package com.xgkj.diyiketang.task;

import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.ProtocolConst;
import com.xgkj.diyiketang.data.SchoolReportDeailInfo;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Tao on 2017/4/11.
 */

public class ReportDeailInfoTask extends CouponHttpBaseTask {
    private String diaryId;
    private static final String COMMENTLISTJSON = "data";

    public ReportDeailInfoTask(String diaryId) {
        super(TaskType.REPORTDEAIL_TASK);
        this.diaryId = diaryId;
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        JSONObject json = response.getBody();
        SchoolReportDeailInfo info = new SchoolReportDeailInfo();
        Log.e("3s",json.getString("data"));
        if(json != null){
            info = JSON.parseObject(json.getString("data"), SchoolReportDeailInfo.class);
        }
        Log.e("3s",info.getDairyContent());
        notifyTaskCompleted(TaskResultCode.SUCCESS,info);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest request = new CouponHttpRequest(RequestType.REPORTDEAIL_REQUEST);
            JSONObject json = new JSONObject();
            json.put("diaryId", diaryId);
//            json.put("imageId",mImageId);
            request.setData(json.toString());
            request.setApiNo(ApiNo.REPORTDEAIL);
            addRequest(request);
        }
    }
}
